
function init_twitter() {
    	
	//twitter reader
		$("#twitter").getTwitter({userName:"Lementstudios",numTweets:8,loaderText:"Loading tweets...",slideIn:true,showHeading:false,showProfileLink:true})
	
}

function init_player() {
    			

// Local copy of jQuery selectors, for performance.
	var	my_jPlayer = $("#jquery_jplayer");
	// Some options
	var	opt_play_first = false, // If true, will attempt to auto-play the default track on page loads. No effect on mobile devices, like iOS.
		opt_auto_play = true, // If true, when a track is selected, it will auto-play.
		first_track = true; // A flag to capture the first track


	// Instance jPlayer
	my_jPlayer.jPlayer({
		ready: function () {
			//setTimeout(function () {$("#jp_container .track-default").click();}, 2000);
			//$("#jp_container .track-default").click();
			//$(this).jPlayer("setMedia", {mp3: "audio/mp3/music.mp3"});			
		},
		repeat: function(event) { // Override the default jPlayer repeat event handler				
				$(this).bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
					$(this).jPlayer("play");
				});			
		},

		swfPath: "js",
		cssSelectorAncestor: "#jp_container",
		supplied: "mp3",
		wmode: "window"
		
	});


	// Create click handlers for the different tracks
	$("#jp_container .track").click(function(e) {

		my_jPlayer.jPlayer("setMedia", {
			mp3: $(this).attr("href")
		});
		
		//if((opt_play_first && first_track) || (opt_auto_play && !first_track)) {
			my_jPlayer.jPlayer("play");
		//}
		
		first_track = false;
		$(this).blur();
		return false;
	});
	

	

}

function init_slides() {
    
	////// slider //////
	$('#slides').slides({
		effect: 'fade',
		fadeSpeed:700,
		preload: true,
		play: 5000,
		pause: 5000,
		generateNextPrev: false,
		generatePagination: true,
		crossfade: true,
		hoverPause: true,
		animationStart: function(current){
			$('.caption').animate({right:'-748px'});
			if (window.console && console.log) {
				console.log('animationStart on slide: ', current);
			};
		},
		animationComplete: function(current){
			$('.caption').animate({right:'141px'});
			if (window.console && console.log) {
				console.log('animationComplete on slide: ', current);
			};
		},
		slidesLoaded: function() {
			$('.caption').animate({right:'141px'});
		}
	});
    
    
    	$(function(){				
			$('#slideshow').cycle({
				timeout:  7,
				fx:      'fade,scrollUp,fade,scrollDown', 
				speed:    2000, 
				pager:   '#nav'
			});	
			$('.slide-bot').hover(
				function(){$(this).find('.banner').stop().animate({right:'0px'}, 300, 'easeOutBack')},
				function(){$(this).find('.banner').stop().animate({right:'-300px'}, 300, 'easeInBack')}
			)		
			
			}); 
            
            
            
            
            
              
        var carousel = $("#carousel").featureCarousel({
          // include options like this:
          // (use quotes only for string values, and no trailing comma after last option)
          // option: value,
          // option: value
        });

        $("#but_prev").click(function () {
          carousel.prev();
        });
        $("#but_next").click(function () {
          carousel.next();
        });
		
     
    $(function(){
	$('#coin-slider').coinslider();
	$('#cs-title-coin-slider').hover(
		function(){$(this).stop().animate({bottom:0}, 200)},
		function(){$(this).stop().animate({bottom:-81}, 200)}
	);
});
}

function init_tour() {
    	
			jQuery('#mycarousel-1').jcarousel({
				horisontal: true,
				wrap:'circular',
				scroll:1,
				easing:'easeInOutBack',
				animation:1200
			});
	
		$(function(){
			$('.hover-caption').hover(
				function(){$(this).parent().find('.caption-1').stop().animate({top:0})},
				function(){$(this).parent().find('.caption-1').stop().animate({top:-228})}
			)
		});
    
}

function init_discography() {
    	
	////// discography slider //////
	$('#slider-1').bxSlider({
			  mode: 'vertical',
			  pager: true,
			  infiniteLoop: false,
			  mouseWheel: false,
		      easing:'easeOutQuad',
		      auto:true,
		      pause:8000,
			  moveSlideQty: 1
		  });
}

function init_blog () {
    
		  
	$("#blog").jCarouselLite({
			btnNext: ".next1",
		 	btnPrev: ".prev1",
       		mouseWheel: true,
			visible: 1,
			speed: 800,
			easing: 'easeOutQuad'
	});		  
    
    	
	// blog arrow button
	$('.prev, .next').css({opacity:1.0})
	
	// blog arrow button hover
	$('.prev, .next').hover(function(){
		$(this).stop().animate({opacity:0.5})					   
	}, function(){
		$(this).stop().animate({opacity:1.0})					   
	})
		  
}

function init_news() {
    	////// news hovers //////
	$('.date, .news a').css({opacity:1})
	$('.date, .news a').hover(function(){
	$(this).find('.img_act').stop().animate({opacity:0})
	}, function(){
	$(this).find('.img_act').stop().animate({opacity:1})
	}) 
}



function init_video() {
    
    	
	////// video 1 //////
	$('.video1').find('span').css({opacity:0})
	
	$('.video1 > a').hover(function(){
		$(this).find('span').stop().animate({opacity:0.5},400)	
		$(this).find('.img_act').stop().animate({opacity:0},400)
	}, function(){
		$(this).find('span').stop().animate({opacity:0},400)
		$(this).find('.img_act').stop().animate({opacity:1},400)
		
	});
	

	
	/////////// prev next
	$('.prev1 span, .next1 span').css({opacity:'0'})
	
	$('.prev1, .next1').hover(function(){
		$(this).find('span').stop().animate({opacity:'1'})							 
	}, function(){
		$(this).find('span').stop().animate({opacity:'0'})							 
	})
	
		$(function(){
		$('#loopedSlider').loopedSlider({
			autoStart: 0,
			hoverPause: true,
			containerClick:false
		});
		
	});
    
}


function init_gallery() {
    	
	
	
	////// gallery //////
	$('.photo1').find('span').css({opacity:0})
	
	$('.photo1 > a').hover(function(){
		$(this).find('span').stop().animate({opacity:0.7},400)								
	}, function(){
		$(this).find('span').stop().animate({opacity:0},400)								
	})


	////// for lightbox //////
	 $("a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'dark_square',social_tools:false,allow_resize: true,default_width: 500,default_height: 344})


}



$(document).ready(function() {
     ////// ** hover animations ** //////
	 
  ////// bg slider  button //////
	$('#pagination1 a').css({opacity:0.75})
	////// bg slider  button hover //////
	$('#pagination1 a').hover(function(){
		$(this).stop().animate({opacity:1})					   
	}, function(){
		$(this).stop().animate({opacity:0.75})					   
	})	
	


	
	////// social icons //////
	$("#social").mouseenter(function() {
    $(this).stop().animate({top:0},500,'easeOutQuint')
  }).mouseleave(function() {
    $(this).stop().animate({top:-52},500,'easeOutQuint')
  });
	
	////// hover icons //////
	$('.icons .img_act').css({opacity:0})
	$('.icons a').hover(function(){
	$(this).find('.img_act').stop().animate({opacity:1})
	}, function(){
	$(this).find('.img_act').stop().animate({opacity:0})
	}) 

    //////  thumbvr thumb scroller //////
	$('.thumbvr')
		.thumbvr({
			duration:1200,
			easing:'easeOutBack'
	 })
	 
	////// thumbvr hover //////
	$('.photo_thumb').find('span').css({opacity:0})
	$('.photo_thumb > a').hover(function(){
		$(this).find('span').stop().animate({opacity:0.75},400)								
	}, function(){
		$(this).find('span').stop().animate({opacity:0},400)								
	})
	
	////// project title hover //////
    $('#button1').css({opacity:1.0})	
	$('#button1').hover(function() {
    $(this).find('.img_act').stop().animate({opacity:0.1},400)
	}, function(){
	$(this).find('.img_act').stop().animate({opacity:1},400)
  });
  
    $('.button2 span, .button3 span').css({opacity:0, display:'none'})
	
	// button 1
	$('.button2, .button3').hover(function(){
		$(this).find('span').css({display:'block'}).stop().animate({opacity:1}, function(){$(this).css({opacity:'none'})})						 
	}, function(){
		$(this).find('span').stop().animate({opacity:0}, function(){$(this).css({display:'none'})})						 
	})
	
  
    ////// shuttle hover //////
    $('.scroll-shuttle').css({opacity:1.0})	
	$('.scroll-shuttle').hover(function() {
    $(this).find('.img_act').stop().animate({opacity:0.1},400)
	}, function(){
	$(this).find('.img_act').stop().animate({opacity:1},400)
  });

	////// sub menu //////
	$('ul#menu').superfish({
      delay:       200,
      animation:   {height:'show'},
      speed:       500,
      autoArrows:  false,
      dropShadows: true
    });

	
	////// mp3 button //////
	$('.mp3_button span').css({opacity:'0'})
	$('.mp3_button').find('.img_act').css({opacity:'0'})
	
	////// mp3 button hover //////
	$('.mp3_button').hover(function(){
		$(this).find('span').stop().animate({opacity:'1'});
		$(this).find('.img_no').stop().animate({opacity:0},400);
		$(this).find('.img_act').stop().animate({opacity:1},400);
		
	}, 
	function(){
		$(this).find('span').stop().animate({opacity:'0'})	;
		$(this).find('.img_no').stop().animate({opacity:1},400);
		$(this).find('.img_act').stop().animate({opacity:0},400);
	})

	
	
       
	
	

}); //// ready


function init_contact() {
    $('#contact-form, #contact-form1').forms({
		ownerEmail:'#'
	});
}

function init_map() {
      
    var mapUrl = "http://maps.google.ca/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=101+Main+Street,+Hamilton,+Ontario&amp;aq=0&amp;sll=49.891235,-97.15369&amp;sspn=45.88126,135.263672&amp;ie=UTF8&amp;hq=&amp;hnear=101+Main+St+E,+Hamilton,+Hamilton+Division,+Ontario+L8N+1G3&amp;ll=43.254415,-79.86562&amp;spn=0.00629,0.016512&amp;z=14&amp;layer=c&amp;cbll=43.254339,-79.865402&amp;panoid=XwFoKWBN9VhKvKJhuHXcuw&amp;cbp=12,188.47,,0,0&amp;output=svembed",
        onLoadWebSite = true,
        googleMapHolder = $(".google_map"),
        backgroundColor = googleMapHolder.css("backgroundColor"),
        mapWidth=parseInt(googleMapHolder.css("width")),
        mapHeight=parseInt(googleMapHolder.css("height")),
        borderTopLeftRadius = parseInt(googleMapHolder.css("borderTopLeftRadius")),
        borderTopRightRadius = parseInt(googleMapHolder.css("borderTopLeftRadius")),
        borderBottomLeftRadius = parseInt(googleMapHolder.css("borderTopLeftRadius")),
        borderBottomRightRadius = parseInt(googleMapHolder.css("borderTopLeftRadius")),
        addMap=false;
	    
    if(backgroundColor == "rgba(0, 0, 0, 0)"){
        backgroundColor= "#000000";
    }
    verificationPageHandler();
    if(onLoadWebSite == false){
        $(window).bind("hashchange", verificationPageHandler);
    }
    function verificationPageHandler(){
        if(onLoadWebSite == false){
        	var idPage = "#"+window.location.hash.substring(3, window.location.hash.length);
        	if(idPage != "#"){
				if(googleMapHolder.parents(idPage).length != 0){
	                addGoogleMapHandler();
       			}	
        	}
        }else{
            addGoogleMapHandler();
        }
    }
    function addGoogleMapHandler(){
        if(!addMap){
            addMap = true;
            $(window).unbind("hashchange", verificationPageHandler);
            googleMapHolder.css({"overflow":"hidden"});
            googleMapHolder.html("<div style='position:absolute; overflow:hidden; width:"+mapWidth+"px; height:"+mapHeight+"px;'><iframe style='position:absolute; margin:-2px 0 10px -2px; border:0px; border-top-left-radius:"+(borderTopLeftRadius+8)+"px; border-top-right-radius:"+(borderTopRightRadius+8)+"px; border-bottom-right-radius:"+(borderBottomLeftRadius+8)+"px; border-bottom-left-radius:"+(borderBottomRightRadius+8)+"px;' width='"+(mapWidth+4)+"px' height='"+(mapHeight+4)+"px' src='"+mapUrl+"'></iframe><div id='loaderPart' style='margin:0; position:absolute; width:"+mapWidth+"px; height:"+(mapHeight)+"px; background:"+backgroundColor+" url(images/loader.gif) no-repeat 50%; border-top-left-radius:"+borderTopLeftRadius+"px; border-top-right-radius:"+borderTopRightRadius+"px; border-bottom-right-radius:"+borderBottomLeftRadius+"px; border-bottom-left-radius:"+borderBottomRightRadius+"px;'></div></div>");
            googleMapHolder.find("iframe").load(googleMapLoadCompleteHandler);
        }
    }
    function googleMapLoadCompleteHandler(){
    	var loaderPart = googleMapHolder.find("#loaderPart");
        loaderPart.delay(100).fadeOut(500, function(){loaderPart.css({"display":"none"});});
    }
}

function init_arrows()
 {
    	
	////// left right nav arrows //////
	$('.prev span,.next span').css({opacity:'0'})
	
	$('.prev,.next').hover(function(){
		$(this).find('span').stop().animate({opacity:'1'})							 
	}, function(){
		$(this).find('span').stop().animate({opacity:'0'})							 
	});
    
    $("a.next, a.prev").click(function(event) {
        page=$(this).attr("href");
        page="#"+page.substr(3);
       // alert(page);
        load_content("",page);
                
    });
    
      $("a.button2, a.button1, .gallery_nav a, .innerlink").click(function(event) {
        page=$(this).attr("href");
        page="#"+page.substr(3);
       // alert(page);
        load_content("",page);
                
    });
    
    
    //alert("arrows done");
 }
 
 
function init_scroll() {
    	// scroll
	$('.scroll').cScroll({
		duration:700,
		step:100,
		trackCl:'scroll-track',
		shuttleCl:'scroll-shuttle',
		upButtonCl:'_up-butt',
		downButtonCl:'_down-butt'
	})	
	
    
}

$(window).load(function() {	
    
    init_arrows();
				
     // top header animation in
	$('.top1').animate({right:'-3000'},0,function(){$(this).animate({right:0},2000,'easeOutQuint');})
	
	// social icons animation in
	$('#social').animate({top:'-100'},0,function(){$(this).animate({top:-52},2000,'easeOutQuint');})
	
	$('.bot1').animate({right:'-3000'},0,function(){$(this).animate({right:0},2000,'easeOutQuint');})
	
	// thumb sroller animation in
	$('.thumbvr').animate({left:'3000'},0,function(){$(this).animate({left:0},4500,'easeOutQuint');})
	
	//scroll title animation in
	$('.scroll_title').animate({left:'-4000'},0,function(){$(this).animate({left:0},8500,'easeOutQuint');})
	
	// thumb sroller animation in
	$('.slogan1').animate({left:'0'},0,function(){$(this).animate({left:360},2000,'easeOutBounce');})
	
	$('.slogan2').animate({left:'0'},0,function(){$(this).animate({left:405},2500,'easeOutBounce');})
	
	$('.slogan3').animate({left:'0'},0,function(){$(this).animate({left:380},3000,'easeOutBounce');})
	
	// bg slider pagination animation in
	$('#pagination1').animate({top:'-200'},400,function(){$(this).animate({top:59},2500,'easeOutQuint');})
						
     $('#bgStretch').bgStretch({
			align:'leftTop',
			navigs:$('#pagination1').navigs(),
			autoPlay:false,
			duration:1000,
			sleep:300
		})
		.sImg({
			spinner:$('.bgspinner').css({opacity:1}).hide()
	})
	
	$('#pagination1 li').eq(0).addClass('active');	
	
	
init_scroll();

	
	//content switch
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true
	})	
	nav.navs(function(n, _){
		content.cont_sw(n);		

			
			
			
			Cufon.replace($('> ul > li > a',nav), { fontFamily: 'AmerType Md BT', color:'#72685b'});
			
			if (_.n!=-1) {
			
			Cufon.replace($('> ul > li > a',nav).eq(_.n), { fontFamily: 'AmerType Md BT', color:'#b0a697'});
		}
		
		
	})
	content.cont_sw({
		showFu:function(){
			var _=this		
			
			
			//$('.splash').stop().animate({left:1500},800,'easeInBack', function(){$(this).css({display:'none'})})
			
			$.when(_.li).then(function(){	
				_.next.css({display:'block', left:-1500}).stop().animate({left:0},800, 'easeOutBack', function(){	});	
			});
		},
		hideFu:function(){
			
			
			var _=this
			_.li.stop().animate({left:1500},800, 'easeInBack', function(){
				_.li.css({display:'none'})
			})
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
		}
	})
	nav.navs(0);
	
	
	//////////// center content  //////////////
	
	var h_cont=800;
	function centre() {
		var h=$(document).height();
		if (h>h_cont) {
			m_top=~~(h-h_cont)/2;
		} else {
			m_top=100;
		}
		$('.main_content').stop().animate({marginTop:m_top})
	}
	centre();
	$(window).resize(centre);
	
		init_gallery();
}); /// load
